<template>
	<!-- #ifdef H5 -->
	<view class="header" :class="{borderShow:isBorader}">
		<view class="serch-wrapper acea-row row-middle">
			<view class="logo">
				<image src="../../../static/images/qcode.png" mode=""></image>
			</view>
			<view class="input acea-row row-middle fillet" hover-class="none" @click="goPage"><text class="iconfont icon-xiazai5"></text>
				搜索智能家居</view>
			<view class="messages">
				<view class="count">1</view>
				<image src="../../../static/images/messages.png" mode=""></image>
			</view>
		</view>
	</view>
	<!-- #endif -->
	<!-- #ifdef MP -->
	<view>
		<view class="mp-header">
			<view class="sys-head" :style="{height:sysHeight}"></view>
			<view class="serch-box"  style="height: 43px;">
				<view class="serch-wrapper acea-row row-middle">
					<view class="logo">
						<image src="../../../static/images/qcode.png" mode=""></image>
					</view>
					<navigator url="/pages/goods_search/index" class="input acea-row row-middle fillet" hover-class="none"><text class="iconfont icon-xiazai5"></text>
						搜索智能家居</navigator>
						<view class="messages">
							<view class="count">1</view>
							<image src="../../../static/images/messages.png" mode=""></image>
						</view>
				</view>
			</view>
		</view>
	</view>
	<!-- #endif -->
</template>

<script>
	let app = getApp();
	let statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	import { goPage } from '@/libs/order.js'
	export default {
		name: 'a_headerSerch',
		props: {
			dataConfig: {
				type: Object,
				default: () => {}
			},
			activeName:{
				type:String,
				default:''
			}
		},
		watch:{
			activeName(nVal,oVal){
				if(nVal == this.name && app.globalData.isIframe){
					this.isBorader = true
				}else{
					this.isBorader = false
				}
			}
		},
		data() {
			return {
				logoConfig: this.dataConfig.imgUrl.url,
				hotWords: this.dataConfig.hotList.list,
				sysHeight:statusBarHeight,
				isBorader:false,
				name:this.$options.name
			};
		},
		created() {
		},
		mounted(){
			let that = this;
			that.$store.commit('hotWords/setHotWord', that.hotWords);
			// #ifdef MP
			this.$nextTick(function(){
				// 获取小程序头部高度
				let info = uni.createSelectorQuery().in(this).select(".mp-header");
				info.boundingClientRect(function(data) {
					that.marTop = data.height
				}).exec()
			})
			// #endif
		},
		methods: {
			goPage(){
				goPage().then(res=>{
					uni.navigateTo({
						url:'/pages/goods_search/index'
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	/* #ifdef H5 */
	.header {
		width: 100%;
		height: 100rpx;
		background: #fff;
		.serch-wrapper {
			padding: 20rpx 20rpx 0 18rpx;
			.messages{
				width: 52rpx;
				height: 52rpx;
				margin-left: 30rpx;
				position: relative;
				.count{
					width: 26rpx;
					height: 26rpx;
					border-radius: 50%;
					line-height: 26rpx;
					text-align: center;
					background: #CF0519;
					color: #FFFFFF;
					font-size: 18rpx;
					position: absolute;
					z-index: 100;
					top: -5rpx;
					left: 10rpx;
					overflow: hidden;/*内容超出后隐藏*/
					text-overflow: ellipsis;/* 超出内容显示为省略号*/
					white-space: nowrap;/*文本不进行换行*/
				}
				image {
					width: 100%;
					height: 100%;
				}
			}
			.logo {
				width: 42rpx;
				height: 42rpx;
				margin-right: 30rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
			.input {
				width: 560rpx;
				height: 58rpx;
				padding: 0 0 0 30rpx;
				background: rgba(247, 247, 247, 1);
				border: 1px solid rgba(241, 241, 241, 1);
				color: #BBBBBB;
				font-size: 28rpx;
				.iconfont {
					margin-right: 20rpx;
				}
				// 没有logo，直接搜索框
				&.on{
					width: 100%;
				}
				// 设置圆角
				&.fillet{
					border-radius: 29rpx;
				}
				// 文本框文字居中
				&.row-center{
					padding: 0;
				}
			}
		}
	}
	/* #endif */
	/* #ifdef MP */
	.mp-header {
		z-index: 999;
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		background: #fff;
	
		.serch-wrapper {
			height: 100%;
			padding: 20rpx 20rpx 0 18rpx;
			.messages{
				width: 52rpx;
				height: 52rpx;
				margin-left: 30rpx;
				position: relative;
				.count{
					width: 26rpx;
					height: 26rpx;
					border-radius: 50%;
					line-height: 26rpx;
					text-align: center;
					background: #CF0519;
					color: #FFFFFF;
					font-size: 18rpx;
					position: absolute;
					z-index: 100;
					top: -5rpx;
					left: 10rpx;
					overflow: hidden;/*内容超出后隐藏*/
					text-overflow: ellipsis;/* 超出内容显示为省略号*/
					white-space: nowrap;/*文本不进行换行*/
				}
				image {
					width: 100%;
					height: 100%;
				}
			}
			.logo {
				width: 42rpx;
				height: 42rpx;
				margin-right: 30rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
	
			.input {
				width: 305rpx;
				height: 50rpx;
				padding: 0 0 0 30rpx;
				background: rgba(247, 247, 247, 1);
				border: 1px solid rgba(241, 241, 241, 1);
				color: #BBBBBB;
				font-size: 28rpx;
	
				.iconfont {
					margin-right: 20rpx;
				}
				// 没有logo，直接搜索框
				&.on{
					width: 70%;
				}
				// 设置圆角
				&.fillet{
					border-radius: 29rpx;
				}
				// 文本框文字居中
				&.row-center{
					padding: 0;
				}
			}
		}
	}
	/* #endif */
</style>
